package aad.storyboard.model;

import android.graphics.Paint;

public class BlinkAnimation extends EffectAnimation{
	
    
	int counter=0;
	int counterold=0;
    
   private static int foregrndalpha = 255;   

	public BlinkAnimation(int duration, int t) {
		super(duration, t);		
		
	}

	@Override
	public void animate() {
				
		if (counterold+15==counter){
			counterold=counter;			
		if(foregrndalpha > 0)  
    	{  
    		foregrndalpha = 0;  
    		
    		for (GraphicalObject c: this.graphicalObjects)
    		{
        	 Paint paint=c.getPaint();
        	 paint.setAlpha(foregrndalpha);
    		}
    			      	      
    	    
    	}  
    		       
		else 
		{    	 
    		foregrndalpha = 255;          
    		
    		for (GraphicalObject c: this.graphicalObjects)
    		{
        	 Paint paint=c.getPaint();
        	 paint.setAlpha(foregrndalpha);
    		}			
		}
		}
		
		counter++;
	}

	@Override
	public void adjustParameters() {
				
	}
	
	@Override
	public void undo()
	{
		for (GraphicalObject c: this.graphicalObjects)
		{
    	 Paint paint=c.getPaint();
    	 paint.setAlpha(0);
		}
	}

}
